class Url
  attr_reader :parts;
  
  def initialize
    @parts = [];
  end
  
  def self.parse(&block)
    url = new
    url.instance_eval(&block);
    url;
  end
  
  def to_s
    @parts.join(".").gsub("./.", "/");
  end
  
  private
  def method_missing(part, *args)
    p [part, @parts]
    @parts << part;
    self;
  end

end

def url(&block)
  Url.parse(&block).to_s
end

p url{www.actionbarra.com/carro/novo}
